<?php
/***************************************************************
*  Copyright notice
*  (c) 2008, jianyuzhu@gmail.com
*  All rights reserved
*  This script is part of the PPEMI project.
***************************************************************/

//
exit();

//
if( file_exists('stop.php') ) {
	include_once('stop.php');
}

//
set_time_limit(0);

//
require(dirname(dirname(__FILE__)) . '/includes/application_top.php');

//
include_once(CONFIG_PATH . CONFIG_DIR_INCLUDES . 'functions/thumb.function.php');
include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'core.directory.class.php');
include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'core.upload.class.php');
include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'core.file.class.php');
include_once(CONFIG_PATH . CONFIG_DIR_FUNCTIONS . 'thumb.function.php');

//
$dir = 'rehearsals/';

//
//$adb->query("TRUNCATE TABLE `pp_galleries_images`");

//
$dObj = new CoreDirectoryParser(CONFIG_PATH . CONFIG_DIR_UPLOADS_ORIGINS . $dir);
$dObj->parse();
$_dir = $dObj->_dir;
$files = $dObj->getFiles();
//
if( is_array($files) ) {
	include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'module/gallery/gallery.image.class.php');
	$mObj = new GalleryImageBase();
		
	//
	if( isset($_GET['lang']) && $_GET['lang'] == 'zh_tw' ) {
		$albums_id = 2;
		$base_owner = 2;
	} else {
		$albums_id = 2;
		$base_owner = 1;
	}
	
	foreach($files as $key => $file) {
		$upload_file = CONFIG_PATH . CONFIG_DIR_UPLOADS_ORIGINS . $dir . $file['file'];
		
		$upload_fileObj = new CoreFile($upload_file);
		$upload_fileObj->parse();
		
		if( $upload_fileObj->is_image == true ) {
			$image_attribute = $upload_fileObj->getFileAttribute();
			$image_width = $upload_fileObj->getImageWidth();
			$image_height = $upload_fileObj->getImageHeight();
		
			$d = array();
			$d['field_aid'] = $albums_id;
			$d['field_value'] = $dir . $file['file'];
			$d['field_width'] = $image_width;
			$d['field_height'] = $image_height;
			$d['field_name'] = $file['name'];
			$d['field_filename'] = $file['file'];
			
			echo $key;
			$items_ids[] = $mObj->addItem($d);
		}
	}
}//
//
echo 'OK';
//
?>